package LinkedList;


import java.util.*;

public class Main {

    static HashSet<String> set=new HashSet<>();
    static char[] res;
    static StringBuilder sb=new StringBuilder();
    static int max=0;
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        String s = in.next();
        if (s.length()<6)
            System.out.println(0);
        char[] arr=s.toCharArray();
        res=arr;
        dfs(0);
        Iterator<String> iterator = set.iterator();
        while (iterator.hasNext()){
            String next = iterator.next();
            process(next);
        }
        System.out.println(max);
    }
    public static void process(String s){
        int count=0;
        char[] chars = s.toCharArray();
        for (int i=0;i+5<chars.length;i++){
            if (chars[i]=='a'&&chars[i+1]=='c'&&chars[i+2]=='b'&&chars[i+3]=='c'&&chars[i+4]=='c'&&chars[i+5]=='a')
                count++;
        }
        max=Math.max(max,count);
    }
    public static void dfs(int t){
        if (t==res.length-1){
            sb.append(res[t]);
            set.add(sb.toString());
            sb.deleteCharAt(t);
        }

        for (int i=t;i<res.length;i++){
            sb.append(res[t]);
            char temp=res[i];
            res[i]=res[t];
            res[t]=temp;
            dfs(t+1);
            temp=res[i];
            res[i]=res[t];
            res[t]=res[i];
        }
    }

    /*
    * int count=in.nextInt();
        int[] arr=new int[count];
        for (int i=0;i<count;i++){
            arr[i]=in.nextInt();
        }

        Arrays.sort(arr);
        int[] dp=new int[count];
        dp[0]=arr[0];
        for (int i=1;i<arr.length;i++){
            int res=arr[i]+dp[i-1];
            for (int j=i-1;((i-j)*2+1<=i+1)&&j>=0;j--){
                res+=arr[j];
            }
            dp[i]=res;
        }
        System.out.println(dp[count-1]);*/

    /*
    public static int max=Integer.MIN_VALUE;
    public static int[] res=null;
    public static int temp=0;

    public static void process(int t){
        if (t==res.length){
            if (temp%7==0){
                max=Math.max(temp,max);
            }
            return;
        }
        temp+=res[t];
        process(t+1);
        temp-=res[t];
        process(t+1);
    }*/
}
